package org.jwcloud.project.module.zx.timingAnalyse.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jwcloud.project.module.zx.common.FmtUtil;
import org.jwcloud.project.module.zx.common.Resp;
import org.jwcloud.project.module.zx.timingAnalyse.service.repository.DoingAnalyseRepository;
import org.jwcloud.project.module.zx.timingAnalyse.service.repository.TimingAnalyseRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DoingAnalyseServiceImpl implements DoingAnalyseService{

	@Autowired
    public DoingAnalyseRepository doingAnalyseRepository;
	
	@Override
	public Resp<Object> queryTitleData(Map param) {
		// TODO Auto-generated method stub
		return Resp.success(this.doingAnalyseRepository.queryTitleData(param));
	}

	@Override
	public Resp<Object> queryStepBar(Map param) {
		// TODO Auto-generated method stub
//		List<Map<String, String>> list = this.doingAnalyseRepository.queryStepBar(param);
//		Map res = new HashMap();
//		res.put("vdesc", FmtUtil.buildListCommon(list, "app_phase_desc"));
//		res.put("value", FmtUtil.buildListCommon(list, "warn_num"));
//		;
//		return Resp.success(res);
		
		return Resp.success(FmtUtil.buildResCommon(this.doingAnalyseRepository.queryStepBar(param)
				, "vdesc", "app_phase_desc"
				, "value", "warn_num"));
	}
//app_phase
//	private List<Object> build(List<Map<String, String>> list, String flag) {
//		List<Object> res = new ArrayList();
//		for(Map<String, String> map: list) {
//			res.add(map.get(flag));
//		}
//		return res;
//	}
	
	@Override
	public Resp<Object> queryProTypePie(Map param) {
		// TODO Auto-generated method stub
		List<Map<String, String>> list = this.doingAnalyseRepository.queryProTypePie(param);
		return Resp.success(list);
	}

	@Override
	public Resp<Object> queryDurSumLine(Map param) {
		// TODO Auto-generated method stub
		Map res = new HashMap();
		Map<String, String> map = this.doingAnalyseRepository.queryDurSumLine(param);
		List<Object> l1 = new ArrayList();
		List<Object> l2 = new ArrayList();
		l1.add("半年");
		l1.add("一年");
		l1.add("两年");
		l1.add("三年");
		l1.add("四年");
		l1.add("五年");
		
		l2.add(map.get("half_year"));
		l2.add(map.get("year1"));
		l2.add(map.get("year2"));
		l2.add(map.get("year3"));
		l2.add(map.get("year4"));
		l2.add(map.get("year5"));
		
		res.put("vdesc", l1);
		res.put("value", l2);
		return Resp.success(res);
	}

	@Override
	public Resp<Object> queryWarnTop(Map param) {
		// TODO Auto-generated method stub
		Map res = FmtUtil.buildResCommon(this.doingAnalyseRepository.queryWarnTop(param)
				, "vdesc", "project_name"
				, "warn1", "warn1_num"
				, "warn2", "warn2_num");
		List list = new ArrayList();
		list.add("一次预警");
		list.add("二次预警");
		res.put("title", list);
		return Resp.success(res);
	}

	@Override
	public Resp<Object> queryDeptPie(Map param) {
		// TODO Auto-generated method stub
		return Resp.success(this.doingAnalyseRepository.queryDeptPie(param));
	}
	
//---------------------------
	
	@Override
	public Resp<Object> queryTitleData_gd(Map param) {
		// TODO Auto-generated method stub
		return Resp.success(this.doingAnalyseRepository.queryTitleData_gd(param));
	}

	@Override
	public Resp<Object> queryProTypePie_gd(Map param) {
		// TODO Auto-generated method stub
		return Resp.success(this.doingAnalyseRepository.queryProTypePie_gd(param));
	}

	@Override
	public Resp<Object> queryYzdwTop_gd(Map param) {
		// TODO Auto-generated method stub
		return Resp.success(this.doingAnalyseRepository.queryYzdwTop_gd(param));
		//return Resp.success("业主单位现在没有");
	}

	@Override
	public Resp<Object> queryFiveYear_gd(Map param) {
		// TODO Auto-generated method stub
		
		return Resp.success(FmtUtil.buildResCommon(this.doingAnalyseRepository.queryFiveYear_gd(param)
				, "vdesc", "year_flag"
				, "value", "value"));
		
		//return Resp.success(this.doingAnalyseRepository.queryFiveYear_gd(param));
	}

	@Override
	public Resp<Object> queryWarnTop_gd(Map param) {
		// TODO Auto-generated method stub
		
		Map res = FmtUtil.buildResCommon(this.doingAnalyseRepository.queryWarnTop_gd(param)
				, "vdesc", "project_name"
				, "warn1", "warn1_num"
				, "warn2", "warn2_num");
		List list = new ArrayList();
		list.add("一次预警");
		list.add("二次预警");
		res.put("title", list);
		
		return Resp.success(res);
		
//		return Resp.success(this.doingAnalyseRepository.queryWarnTop_gd(param));
	}

	@Override
	public Resp<Object> queryDeptPie_gd(Map param) {
		// TODO Auto-generated method stub
		return Resp.success(this.doingAnalyseRepository.queryDeptPie_gd(param));
	}

}
